<%@ page import="com.biz.conf.Global" %>
<%@ include file="/jsp/taglib.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>信息编辑窗体</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">

    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <%--<link href="${ctxStatic}/plugins/h+/css/style.min862f.css?v=4.1.0" rel="stylesheet">--%>
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/cropper/cropper.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/switchery/switchery.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/jasny/jasny-bootstrap.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/nouslider/jquery.nouislider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/clockpicker/clockpicker.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
<style>
    .posrelative{
        position:relative;
    }
    .postext{
        position: absolute;
        right:20px;
        top:6px;
    }
</style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>充值久零币</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm" onsubmit="return  false">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">手机号码：</label>
                            <div class="col-sm-8">
                                <div class="row">
                                    <div class="col-lg-6">
                                        <div class="input-group">
                                            <i class="clearable fa fa-remove"></i>
                                            <input type="text" class="form-control" id="targetUser" name="jiuLingCoinHistory.targetUser">
                                            <div class="input-group-btn">
                                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                                    选择
                                                    <span class="caret"></span>
                                                </button>
                                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                                </ul>
                                            </div>
                                            <!-- /btn-group -->
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">久零贝金额：</label>
                            <div class="col-sm-8 posrelative">
                                <input type="text" id="amount1" name="jiuLingCoinHistory.amount1" value="" class="form-control" /><span class="postext">元</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">类型：</label>
                            <div class="col-sm-8">
                                <select class="select2 form-control"  id="type" name="jiuLingCoinHistory.type">
                                    <c:choose>
                                        <c:when test="${jiuLingCoin_History.type eq 0}">
                                            <option selected="selected" value="0">充值金额</option>
                                            <option value="1">赠送金额</option>
                                        </c:when>
                                        <c:otherwise>
                                            <option value="0">充值金额</option>
                                            <option selected="selected" value="1">赠送金额</option>
                                        </c:otherwise>
                                    </c:choose>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">理由：</label>
                            <div class="col-sm-8">
                                <textarea id="reason" name="jiuLingCoinHistory.reason" maxlength="255" class="form-control ">
                                    ${jiuLingCoin_History.reason}
                                </textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button class="btn btn-primary" onclick="doSave();">提交</button>
                                <button id="btn_close1"  class="btn btn-primary" type="button">关闭</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${ctxStatic}/plugins/h+/js/jquery.min.js"></script>
<link href="${ctxStatic}/plugins/h+/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
<script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/suggest/bootstrap-suggest.min.js"></script>
<script>
    var index = parent.layer.getFrameIndex(window.name);
    $(function(){
        var dataList =null;
        /**
         * 从 data参数中过滤数据
         */
        var url="${ctx}/recharge/queryUserList.ac";
        $.get(url,function(data){
            data=eval("("+data+")");
            var dataList = {value: []}, i = data.length;
            while(i--) {
                console.log("dataList:"+data[i].id);
                dataList.value.push({
                    id: data[i].id,
                    phone: data[i].phone,
                    description: data[i].person_name
                });
            }
            /**
             * 测试(modal 中显示；不自动选中值；不显示按钮)
             */
            $("#targetUser").bsSuggest({
                data: dataList,
                indexKey: 1, //data.value 的第几个数据，作为input输入框的内容
                indexId: 0,  //data.value 的第几个数据，作为input输入框的内容
                effectiveFields:["phone","description"],
                effectiveFieldsAlias:["手机号码","用户姓名"]
            }).on('onDataRequestSuccess', function (e, result) {
                console.log('onDataRequestSuccess: ', result);
            }).on('onSetSelectValue', function (e, keyword, data) {
                console.log('onSetSelectValue: ', keyword, data);
            }).on('onUnsetSelectValue', function () {
                console.log("onUnsetSelectValue");
            });
        });

        //initTest();

        $("#btn_close1").click(function(){
            parent.layer.close(index);
        });
    });

    function initTest() {
        $("#targetUser").bsSuggest('init', {
            clearable: true,
            url: "${ctx}/recharge/queryUserList.ac",
            idField: "id",
            keyField: "phone"
        }).on('onDataRequestSuccess', function (e, result) {
            console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword, data) {
            console.log('onSetSelectValue: ', keyword, data);
        }).on('onUnsetSelectValue', function () {
            console.log('onUnsetSelectValue');
        });
    }


    //保存
    function doSave(){
        var targetUser=$("#targetUser").val();
        var amount1=$("#amount1").val();
        var type=$("#type").val();
        var reason=$("#reason").val();


        var flag=true;
        if(targetUser==null||targetUser==undefined||targetUser==''){alert("请输入目标用户");flag= false;}
        if(amount1==null||amount1==undefined||amount1==''||isNaN(amount1)){alert("请输入非零正整数金额");flag= false;}
        if(type==null||type==undefined||type==''){alert("请选择充值类型");flag= false;}


        if(flag){
            $.ajax({
                url:'${pageContext.request.contextPath}/recharge/doInsert.ac',// 跳转到 action
                data:$("#signupForm").serialize(),
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    if(data=="保存成功")
                    {
                        alert("操作成功！");
                        parent.frames["iframe6"].refresh();
                        parent.layer.close(index);
//                        window.top.reload();
                    }else
                    {
                        alert(data);
                    }
                },
                error : function() {
                    alert("操作失败！");
                }
            });
        }
    }


</script>

</body>

</html>

